define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'system.room_config/index',
        add_url: 'system.room_config/add',
        edit_url: 'system.room_config/edit',
        delete_url: 'system.room_config/delete',
        modify_url: 'system.room_config/modify'
    };

    var Controller = {

        index: function () {

            ea.table.render({
                init: init,
                toolbar:['refresh'],
                defaultToolbar:['filter', {
                    title: '搜索',
                    layEvent: 'TABLE_SEARCH',
                    icon: 'layui-icon-search',
                    extend: 'data-table-id="' + 'user_group' + '"'
                }],
                cols: [[
                    {type: "checkbox"},
                    {field: 'roomid', width: 150, title: '房间号',templet:function (e) {
                        let html = ``
                        html += `` + e.roomid
                        if (e.roomid == 888) {
                            html += `<div style="margin-left:10px;color:#FFFFFF;background:rgb(75, 179, 104);line-height:22px;font-size:12px;width:60px;display:inline-block">开会房间</div>`
                        }else if(e.roomid == 999) {
                            html += `<div style="margin-left:10px;color:#FFFFFF;background:rgb(75, 179, 104);line-height:22px;font-size:12px;width:60px;display:inline-block">主房间</div>`

                        }
                        return html
                    }},
                    {field: 'roomslink',title:"链接",search:false,templet:function (e) {
                        return `<a target='_blank' style="text-decoration:underline;color:blue" href='`+e.roomslink+`'>`+e.roomslink+`</a>`
                    }},
                    {field: 'status', title: '房间状态', templet:function (e) {
                        if (e.status == 0) {
                            return "关闭"
                        }else{
                            return "开启"
                        }
                    }},
                    {
                        width: 250,
                        title: '操作',
                        templet: ea.table.tool,
                        operat:[
                            'edit'
                        ]
                    }
                ]],
            });

            
            ea.table.listenSwitch({filter: 'status', url: init.modify_url});

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            
            if ($("#ispass").prop("checked")) {
                $("#password").show()
            }else{
                $("#password").hide()
            }
            ea.listen();
        },
        password: function () {
            ea.listen();
        }
    };
    return Controller;
}); 